/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package bd.org.apache.commons.math.linear;

import bd.org.apache.commons.math.exception.DimensionMismatchException;

/**
 * This class defines a linear operator operating on real ({@code double})
 * vector spaces. No direct access to the coefficients of the underlying matrix
 * is provided.
 * The motivation for such an interface is well stated by
 * <a href="#BARR1994">Barrett et al. (1994)</a>:
 * <blockquote>
 * We restrict ourselves to iterative methods, which work by repeatedly
 * improving an approximate solution until it is accurate enough. These
 * methods access the coefficient matrix A of the linear system only via the
 * matrix-vector product y = A &middot; x
 * (and perhaps z = A<sup>T</sup> &middot; x). Thus the user need only
 * supply a subroutine for computing y (and perhaps z) given x, which permits
 * full exploitation of the sparsity or other special structure of A.
 * </blockquote>
 * <br/>
 * <dl>
 * <dt><a name="BARR1994">Barret et al. (1994)</a></dt>
 * <dd>
 * R. Barrett, M. Berry, T. F. Chan, J. Demmel, J. M. Donato, J. Dongarra,
 * V. Eijkhout, R. Pozo, C. Romine and H. Van der Vorst,
 * <em>Templates for the Solution of Linear Systems: Building Blocks for
 * Iterative Methods</em>, SIAM
 * </dd>
 * </dl>
 *
 * @version $Id: RealLinearOperator.java 1244107 2012-02-14 16:17:55Z erans $
 * @since 3.0
 */
public abstract class RealLinearOperator {

    /**
     * Returns the dimension of the codomain of this operator.
     *
     * @return the number of rows of the underlying matrix
     */
    public abstract int getRowDimension();


    /**
     * Returns the dimension of the domain of this operator.
     *
     * @return the number of columns of the underlying matrix
     */
    public abstract int getColumnDimension();


    /**
     * Returns the result of multiplying {@code this} by the vector {@code x}.
     *
     * @param x the vector to operate on
     * @return the product of {@code this} instance with {@code x}
     */
    public abstract RealVector operate(final RealVector x);


    /**
     * Returns the result of multiplying the transpose of {@code this} operator
     * by the vector {@code x} (optional operation). The default implementation
     * throws an {@link UnsupportedOperationException}. Users overriding this
     * method must also override {@link #isTransposable()}.
     *
     * @param x the vector to operate on
     * @return the product of the transpose of {@code this} instance with
     *         {@code x}
     *
     * @throws DimensionMismatchException
     * @throws UnsupportedOperationException if this operation is not supported
     * by {@code this} operator
     */
    public RealVector operateTranspose(final RealVector x)
            throws DimensionMismatchException, UnsupportedOperationException {

        throw new UnsupportedOperationException();
    }


    /**
     * Returns {@code true} if this operator supports
     * {@link #operateTranspose(RealVector)}. If {@code true} is returned,
     * {@link #operateTranspose(RealVector)} should not throw
     * {@code UnsupportedOperationException}. The default implementation returns
     * {@code false}.
     *
     * @return {@code false}
     */
    public boolean isTransposable() {

        return false;
    }
}
